xen.git
13 years agolibxl: provide libxl__xs_*_checked and libxl__xs_transaction_*
Ian Jackson [Thu, 28 Jun 2012 17:43:22 +0000 (18:43 +0100)]
libxl: provide libxl__xs_*_checked and libxl__xs_transaction_*

These useful utility functions make dealing with xenstore a little
less painful.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl: rename libxl_dom:save_helper to physmap_path
Ian Jackson [Thu, 28 Jun 2012 17:43:22 +0000 (18:43 +0100)]
libxl: rename libxl_dom:save_helper to physmap_path

"save_helper" isn't very descriptive.  Also it is now confusing
because it reads like it might refer to the libxl-save-helper
executable which runs xc_domain_save and xc_domain_restore.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
13 years agolibxl: domain save/restore: run in a separate process
Ian Jackson [Thu, 28 Jun 2012 17:43:21 +0000 (18:43 +0100)]
libxl: domain save/restore: run in a separate process

libxenctrl expects to be able to simply run the save or restore
operation synchronously.  This won't work well in a process which is
trying to handle multiple domains.

The options are:

 - Block such a whole process (eg, the whole of libvirt) while
   migration completes (or until it fails).

 - Create a thread to run xc_domain_save and xc_domain_restore on.
   This is quite unpalatable.  Multithreaded programming is error
   prone enough without generating threads in libraries, particularly
   if the thread does some very complex operation.

 - Fork and run the operation in the child without execing.  This is
   no good because we would need to negotiate with the caller about
   fds we would inherit (and we might be a very large process).

 - Fork and exec a helper.

Of these options the latter is the most palatable.

Consequently:

 * A new helper program libxl-save-helper (which does both save and
   restore).  It will be installed in /usr/lib/xen/bin.  It does not
   link against libxl, only libxc, and its error handling does not
   need to be very advanced.  It does contain a plumbing through of
   the logging interface into the callback stream.

 * A small ad-hoc protocol between the helper and libxl which allows
   log messages and the libxc callbacks to be passed up and down.
   Protocol doc comment is in libxl_save_helper.c.

 * To avoid a lot of tedium the marshalling boilerplate (stubs for the
   helper and the callback decoder for libxl) is generated with a
   small perl script.

 * Implement new functionality to spawn the helper, monitor its
   output, provide responses, and check on its exit status.

 * The functions libxl__xc_domain_restore_done and
   libxl__xc_domain_save_done now turn out to want be called in the
   same place.  So make their state argument a void* so that the two
   functions are type compatible.

The domain save path still writes the qemu savefile synchronously.
This will need to be fixed in a subsequent patch.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl: domain save: API changes for asynchrony
Ian Jackson [Thu, 28 Jun 2012 17:43:21 +0000 (18:43 +0100)]
libxl: domain save: API changes for asynchrony

Change the internal and external APIs for domain save (suspend) to be
capable of asynchronous operation.  The implementation remains
synchronous.  The interfaces surrounding device model saving are still
synchronous.

Public API changes:

 * libxl_domain_save takes an ao_how.

 * libxl_domain_remus_start takes an ao_how.  If the
   libxl_domain_remus_info is NULL, we abort rather than returning an
   error.

 * The `suspend_callback' function passed to libxl_domain_save is
   never called by the existing implementation in libxl.  Abolish it.

 * libxl_domain_save takes its flags parameter as an argument.
   Thus libxl_domain_suspend_info is abolished.

 * XL_SUSPEND_* flags renamed to LIBXL_SAVE_*.

 * Callers in xl updated.

Internal code restructuring:

 * libxl__domain_suspend_state member types and names rationalised.

 * libxl__domain_suspend renamed from libxl__domain_suspend_common.
   (_common here actually meant "internal function").

 * libxl__domain_suspend takes a libxl__domain_suspend_state, which
   where the parameters to the operation are filled in by the caller.

 * xc_domain_save is now called via libxl__xc_domain_save which can
   itself become asynchronous.

 * Consequently, libxl__domain_suspend is split into two functions at
   the callback boundary; the second half is
   libxl__xc_domain_save_done.

 * libxl__domain_save_device_model is now called by the actual
   implementation rather than by the public wrapper.  It is already in
   its proper place in the domain save execution sequence.  So
   officially make it part of that execution sequence, renaming it to
   domain_save_device_model.

 * Effectively, rewrite the public wrapper functions
   libxl_domain_suspend and libxl_domain_remus_start.

 * Remove a needless #include <xenctrl.h>

 * libxl__domain_suspend aborts on unexpected domain types rather
   than mysteriously returning EINVAL.

 * struct save_callbacks moved from the stack to the dss.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl: domain restore: reshuffle, preparing for ao
Ian Jackson [Thu, 28 Jun 2012 17:43:20 +0000 (18:43 +0100)]
libxl: domain restore: reshuffle, preparing for ao

We are going to arrange that libxl, instead of calling
xc_domain_restore, calls a stub function which forks and execs a
helper program, so that restore can be asynchronous rather than
blocking the whole toolstack.

This stub function will be called libxl__xc_domain_restore.

However, its prospective call site is unsuitable for a function which
needs to make a callback, and is buried in two nested single-call-site
functions which are logically part of the domain creation procedure.

So we first abolish those single-call-site functions, integrate their
contents into domain creation in their proper temporal order, and
break out libxl__xc_domain_restore ready for its reimplementation.

No functional change - just the following reorganisation:

* Abolish libxl__domain_restore_common, as it had only one caller.
  Move its contents into (what was) domain_restore.

* There is a new stage function domcreate_rebuild_done containing what
  used to be the bulk of domcreate_bootloader_done, since
  domcreate_bootloader_done now simply starts the restore (or does the
  rebuild) and arranges to call the next stage.

* Move the contents of domain_restore into its correct place in the
  domain creation sequence.  We put it inside
  domcreate_bootloader_done, which now either calls
  libxl__xc_domain_restore which will call the new function
  domcreate_rebuild_done, or calls domcreate_rebuild_done directly.

* Various general-purpose local variables (`i' etc.) and convenience
  alias variables need to be shuffled about accordingly.

* Consequently libxl__toolstack_restore needs to gain external linkage
  as it is now in a different file to its user.

* Move the xc_domain_save callbacks struct from the stack into
  libxl__domain_create_state.

In general the moved code remains almost identical.  Two returns in
what used to be libxl__domain_restore_common have been changed to set
the return value and "goto out", and the call sites for the abolished
and new functions have been adjusted.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl: domain save: rename variables etc.
Ian Jackson [Thu, 28 Jun 2012 17:43:20 +0000 (18:43 +0100)]
libxl: domain save: rename variables etc.

Preparatory work for making domain suspend asynchronous:

* Rename `struct suspendinfo' to `libxl__domain_suspend_state'
  and move it to libxl_internal.h.

* Rename variables `si' to `dss'.

* Change the stack-allocated state and callbacks from
    struct suspendinfo si;
    struct save_callbacks callbacks;
    struct restore_callbacks callbacks;
  to
    libxl__domain_suspend_state dss[1];
    struct save_callbacks callbacks[1];
    struct restore_callbacks callbacks[1];
  so that it may be referred to as a pointer variable everywhere.

* Rename the variable `flags' (in libxl__domain_suspend_state) to
  `xcflags', to help distinguish it from the other `flags' which is
  passed in from the calling application in libxl_domain_suspend_info.
  Abolish the local variable in libxl__domain_suspend_common, as it
  can use the one in the dss.

* Move the prototypes of suspend-related functions in libxl_internal.h
  to after the definition of the state struct.

* Replace several ctx variables with gc variables and
  consequently references to ctx with CTX.  Change references
  to `dss->gc' in the functional code to simply `gc'.

* Use LOG* rather than LIBXL__LOG* in a number of places.

* In libxl__domain_save_device_model use `rc' instead of `ret'.

* Introduce and use `gc' and `domid' in
  libxl__domain_suspend_common_callback.

* Wrap some long lines.

* Add an extra pair of parens for clarity in a flag test.

* Remove two pointless casts from void* to a struct*.

No functional change whatsoever.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxc: Do not segfault if (e.g.) switch_qemu_logdirty fails
Ian Jackson [Thu, 28 Jun 2012 17:43:19 +0000 (18:43 +0100)]
libxc: Do not segfault if (e.g.) switch_qemu_logdirty fails

In xc_domain_save the local variable `ob' is initialised to NULL.
There are then various startup actions.  Some of these `goto out' on
failure; for example the call to callbacks->switch_qemu_logdirty on
l.978.  However, out is used both by success and error paths.  So it
attempts (l.2043) to flush the current output buffer.  If ob has not
yet been assigned a non-NULL value, this segfaults.  So make the call
to outbuf_flush conditional on ob.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
13 years agolibxc: xc_domain_restore, make toolstack_restore const-correct
Ian Jackson [Thu, 28 Jun 2012 17:43:19 +0000 (18:43 +0100)]
libxc: xc_domain_restore, make toolstack_restore const-correct

Update the one provider of this callback, in libxl.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl: allow setting more than 31 vcpus
Yang Zhang [Thu, 28 Jun 2012 16:51:56 +0000 (17:51 +0100)]
libxl: allow setting more than 31 vcpus

In current implementation, it uses integer to record current avail
cpus and this only allows user to specify 31 vcpus.  In following
patch, it uses cpumap instead integer which make more sense than
before. Also there is no limit to the max vcpus.

Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agolibxl: allow to allocate cpumap with specific size
Yang Zhang [Thu, 28 Jun 2012 16:47:13 +0000 (17:47 +0100)]
libxl: allow to allocate cpumap with specific size

Currently, libxl_cpumap_alloc()allocate the cpumap with size of number
of physical cpus. In some place, we may want to allocate specific size
of cpumap.  This patch allow to pass a argument to specific the size
that you want to allocate. If pass 0, it means the size is equal to
number of physical cpus.

Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agoxen,pod: Only sweep in an emergency, and only for 4k pages
George Dunlap [Thu, 28 Jun 2012 14:18:05 +0000 (15:18 +0100)]
xen,pod: Only sweep in an emergency, and only for 4k pages

Testing has shown that doing sweeps for superpages slows down boot
significantly, but does not result in a significantly higher number of
superpages after boot.  Early sweeping for 4k pages causes superpages
to be broken up unnecessarily.

Only sweep if we're really out of memory.

v2:
 - Move unrelated code-motion hunk to another patch
v3:
 - Remove now-unused reclaim_super from pod struct

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
13 years agoxen,pod: Zero-check recently populated pages (checklast)
George Dunlap [Thu, 28 Jun 2012 14:18:03 +0000 (15:18 +0100)]
xen,pod: Zero-check recently populated pages (checklast)

When demand-populating pages due to guest accesses, check recently populated
pages to see if we can reclaim them for the cache.  This should keep the PoD
cache filled when the start-of-day scrubber is going through.

The number 128 was chosen by experiment.  Windows does its page
scrubbing in parallel; while a small nubmer like 4 works well for
single VMs, it breaks down as multiple vcpus are scrubbing different
pages in parallel.  Increasing to 128 works well for higher numbers of
vcpus.

v2:
 - Wrapped some long lines
 - unsigned int for index, unsigned long for array
v3:
 - Use PAGE_ORDER_2M instead of 9
 - Removed inappropriate use of p2m_pod_zero_check_superpage() return value

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
13 years agoxen,pod: Try to reclaim superpages when ballooning down
George Dunlap [Thu, 28 Jun 2012 14:18:00 +0000 (15:18 +0100)]
xen,pod: Try to reclaim superpages when ballooning down

Windows balloon drivers can typically only get 4k pages from the kernel,
and so hand them back at that level.  Try to regain superpages by checking
the superpage frame that the 4k page is in to see if we can reclaim the whole
thing for the PoD cache.

This also modifies p2m_pod_zero_check_superpage() to return SUPERPAGE_PAGES on
success.

v2:
 - Rewritten to simply to the check as in demand-fault case, without needing
   to know that the p2m entry is a superpage.
 - Also, took out the re-writing of the reclaim loop, leaving it optimized for
   4k pages (by far the most common case), and simplifying the patch.
v3:
 - Add SoB

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
13 years agodocs: Use lists.xen.org not lists.xensource.com
Ian Campbell [Thu, 28 Jun 2012 15:11:59 +0000 (16:11 +0100)]
docs: Use lists.xen.org not lists.xensource.com

[ Also s/greatful/grateful/, twice -iwj ]

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agohgignore/gitignore: add xen/arch/x86/boot/reloc.bin, .lnk
Ian Jackson [Thu, 28 Jun 2012 14:59:24 +0000 (15:59 +0100)]
hgignore/gitignore: add xen/arch/x86/boot/reloc.bin, .lnk

25479:61dfb3da56b0 added a .PRECIOUS which causes these files to be
left over more often.  They should have been ignored already, though.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agoQEMU_TAG update
Ian Jackson [Thu, 28 Jun 2012 14:49:53 +0000 (15:49 +0100)]
QEMU_TAG update

13 years agolibxl: disable msitranslate by default
Stefano Stabellini [Thu, 28 Jun 2012 14:47:34 +0000 (15:47 +0100)]
libxl: disable msitranslate by default

msitranslate is known to cause problems with some device drivers,
because it sets the real device in MSI mode while making the guest think
is actually in legacy interrupts mode. Some drivers are able to spot this
inconsistency and break (Nvidia drivers for example).

Disable msitranslate by default.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agolibxl: do not ignore the per-device msitranslate and power_mgmt opts
Stefano Stabellini [Thu, 28 Jun 2012 14:45:59 +0000 (15:45 +0100)]
libxl: do not ignore the per-device msitranslate and power_mgmt opts

Do not ignore the per-device msitranslate and power_mgmt options: they
need to be appended to the bdf.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agolibxl: document the memory ownership of some functions
Dario Faggioli [Thu, 28 Jun 2012 14:44:02 +0000 (15:44 +0100)]
libxl: document the memory ownership of some functions

Specifying they allocate dynamic memory that needs to be explicitly freed.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agoarm: fix build after c/s 25477:e12e0b038219
Jan Beulich [Thu, 28 Jun 2012 14:04:12 +0000 (16:04 +0200)]
arm: fix build after c/s 25477:e12e0b038219

Only x86 currently has a struct vcpu field arch.gdbsx_vcpu_event. But
as the whole function domain_pause_for_debugger() is pointless to be
compiled when there's no arch support, simply introduce another HAS_*
macro, enabled only on x86.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agoxen,pod: Cosmetic code motion
George Dunlap [Wed, 27 Jun 2012 16:50:10 +0000 (17:50 +0100)]
xen,pod: Cosmetic code motion

No point in doing the assignment if we're just going to crash anyway.

Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
13 years agox86/mm: Clean up unshare path for foreign mappings
Andres Lagar-Cavilla [Thu, 28 Jun 2012 11:45:09 +0000 (12:45 +0100)]
x86/mm: Clean up unshare path for foreign mappings

In its current shape, if Xen unshares a foreign gfn successfully while building
a foreign writable map, it is left with a reference to the old shared page in
the "target" var.

Instead, push unsharing request down on the initial get_page_from_gfn call,
which will DTRT.

This allows for greatly simplifying the unshare related condition handling,
removing ugly comments and s86_64 ifdef-ery.

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
13 years agox86/hvm: increase struct hvm_vcpu_io's mmio_large_read[]
Jan Beulich [Thu, 28 Jun 2012 11:36:08 +0000 (13:36 +0200)]
x86/hvm: increase struct hvm_vcpu_io's mmio_large_read[]

Since the emulator now supports a few 256-bit memory operations, this
array needs to follow (and the comments should, too).

To limit growth, re-order the mmio_large_write_* fields so that the
two mmio_large_*_bytes fields end up adjacent to each other.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agodocs/xen-headers: allow headers to be symlinks
Jan Beulich [Wed, 27 Jun 2012 07:36:43 +0000 (09:36 +0200)]
docs/xen-headers: allow headers to be symlinks

There's no apparent reason not to permit this, and since we don't
support out-of-source-tree builds, the least overhead way of doing
multiple, differently configured (perhaps different architecture)
builds from a single source tree is to create symlinked build trees.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl: fix a typo in the GCREALLOC_ARRAY macro
Dario Faggioli [Tue, 26 Jun 2012 16:00:20 +0000 (17:00 +0100)]
libxl: fix a typo in the GCREALLOC_ARRAY macro

Causing a build failure when trying to use it:

xxx: error: expected ';' before ')' token
xxx: error: expected statement before ')' token

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoarm: fix locking in create_p2m_entries
Ian Campbell [Tue, 26 Jun 2012 15:23:58 +0000 (16:23 +0100)]
arm: fix locking in create_p2m_entries

For some reason we were holding the lock over only the unmaps at the end of
the function, rather than for the whole walk.

We might want to be more clever in the future, but for now lets just lock for
the whole walk+create process.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoarm: map fixmaps non-executable.
Ian Campbell [Tue, 26 Jun 2012 15:23:58 +0000 (16:23 +0100)]
arm: map fixmaps non-executable.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoarm: dump guest s1 walk on data abort which is not a stage 2 issue.
Ian Campbell [Tue, 26 Jun 2012 15:23:57 +0000 (16:23 +0100)]
arm: dump guest s1 walk on data abort which is not a stage 2 issue.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoarm: dump a page table walk when va_to_par fails.
Ian Campbell [Tue, 26 Jun 2012 15:23:56 +0000 (16:23 +0100)]
arm: dump a page table walk when va_to_par fails.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoarm: context switch a bunch of guest state.
Ian Campbell [Tue, 26 Jun 2012 15:23:55 +0000 (16:23 +0100)]
arm: context switch a bunch of guest state.

I haven't investigated what if any of this could be done lazily.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoarm: Add simple cpu_{sibling, core}_mask
Ian Campbell [Tue, 26 Jun 2012 15:23:54 +0000 (16:23 +0100)]
arm: Add simple cpu_{sibling, core}_mask

This needs to be done for all cpus. The allocations require smp_prepare_cpus
to be called a bit later on.

In a previous version of this patch these maps were being zeroed (instead of
setting the CPU itself in them). This in turn causes cpumask_first to return
NR_CPUS, which in turn was causing default_vcpu0_location to misbehave and
read off the end of its cnt array.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoarm: do not set max_vcpus = 8 in arch_domain_create.
Ian Campbell [Tue, 26 Jun 2012 15:23:54 +0000 (16:23 +0100)]
arm: do not set max_vcpus = 8 in arch_domain_create.

XEN_DOMCTL_max_vcpus cannot reduce max_vcpus and therefore we can't create a
smaller guest.

The limit of 8 (due to GIC limits) should be expressed in MAX_VIRT_CPUS.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoarm: implement stub version of flush_tlb_mask.
Ian Campbell [Tue, 26 Jun 2012 15:23:53 +0000 (16:23 +0100)]
arm: implement stub version of flush_tlb_mask.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoarm: stub out sync_vcpu_execstate
Ian Campbell [Tue, 26 Jun 2012 15:23:52 +0000 (16:23 +0100)]
arm: stub out sync_vcpu_execstate

We don't do lazy exec state switching so there isn't actually anything to do.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoarm: remove hard tabs from init_idle_domain
Ian Campbell [Tue, 26 Jun 2012 15:23:51 +0000 (16:23 +0100)]
arm: remove hard tabs from init_idle_domain

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoarm: implement p2m lookup
Ian Campbell [Tue, 26 Jun 2012 15:23:51 +0000 (16:23 +0100)]
arm: implement p2m lookup

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoarm: remove unnecessarily verbose print from p2m_load_VTTBR
Ian Campbell [Tue, 26 Jun 2012 15:23:50 +0000 (16:23 +0100)]
arm: remove unnecessarily verbose print from p2m_load_VTTBR

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoarm: print domid as part of debug trap
Ian Campbell [Tue, 26 Jun 2012 15:23:49 +0000 (16:23 +0100)]
arm: print domid as part of debug trap

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoarm: allocate and setup a guest vcpu.
Ian Campbell [Tue, 26 Jun 2012 15:23:48 +0000 (16:23 +0100)]
arm: allocate and setup a guest vcpu.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoarm: hook up domctl and memory_op
Ian Campbell [Tue, 26 Jun 2012 15:23:47 +0000 (16:23 +0100)]
arm: hook up domctl and memory_op

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoarm: enable interrupts while handling traps
Ian Campbell [Tue, 26 Jun 2012 15:23:47 +0000 (16:23 +0100)]
arm: enable interrupts while handling traps

For most traps we can do this as soon as we have saved the necessary state.
For IRQs and FIQs we must wait until we have acked the interrupt with the GIC.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoarm: restore stack on return from trap.
Ian Campbell [Tue, 26 Jun 2012 15:23:46 +0000 (16:23 +0100)]
arm: restore stack on return from trap.

We align the stack before calling into C code but we weren't undoing this on
return.

Collapse continue_(non)idle_domain into continue_new_vcpu.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoarm: correct and expand TLB flush CP15 registers
Ian Campbell [Tue, 26 Jun 2012 15:23:45 +0000 (16:23 +0100)]
arm: correct and expand TLB flush CP15 registers

Correct spelling of TLBIALLHIS and correct definition of TLBIALLNSNHIS.

Add a few more.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoarm: handy function to print a walk of a page table
Ian Campbell [Tue, 26 Jun 2012 15:23:44 +0000 (16:23 +0100)]
arm: handy function to print a walk of a page table

Include helpers for dumping hypervisor walks and guest p2m walks.

Useful for debug but not actually used in this patch.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoarm: allocate top level p2m page for all non-idle domains
Ian Campbell [Tue, 26 Jun 2012 15:23:43 +0000 (16:23 +0100)]
arm: allocate top level p2m page for all non-idle domains

Not just dom0.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoarm: fix build with gcc 4.7.x
Jan Beulich [Mon, 25 Jun 2012 11:41:32 +0000 (13:41 +0200)]
arm: fix build with gcc 4.7.x

As was already pointed out months ago (see
http://lists.xen.org/archives/html/xen-devel/2012-02/msg00826.html),
gcc 4.7.x (imo validly) refuses to take both -mcpu=cortex-a15 and
-march=armv7-a due to conflicting feature sets causing amibiguity in
instruction selection. Since the former implies the latter, just use
the former (and drop the -march=).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoFix check if guest enabled nested paging.
Christoph Egger [Mon, 25 Jun 2012 09:18:23 +0000 (10:18 +0100)]
Fix check if guest enabled nested paging.

Fixes crashes with Windows guests when shadow-on-nested is used.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Acked-by: Tim Deegan <tim@xen.org>
13 years agolibxl: fix validation of scheduling parameters for sedf
Dario Faggioli [Fri, 22 Jun 2012 16:43:30 +0000 (17:43 +0100)]
libxl: fix validation of scheduling parameters for sedf

2205914617cb does its job in correcting the "wrong domain being
considered" issue introduced by 9d1fd58ff602. Unfortunately, when
dealing (again!) with the sedf scheduler, it is required for the
vCPUs of a domain to have been allocated and setup already (in
the hypervisor), when the first call to libxl_domain_sched_params_get()
happens, and that is not true.

This fixes that by avoiding calling that function at all, as we
only need to know which scheduler the domain is running under,
and that is provided by libxl__domain_scheduler() which is safe
to be called there.

While at it, also improve a bit the comments about the whole
sedf parameter validation and mangling process.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agox86/PCI: pass correct register value to XSM
Daniel De Graaf [Fri, 22 Jun 2012 11:44:54 +0000 (13:44 +0200)]
x86/PCI: pass correct register value to XSM

When attempting to use AMD's extension to access the extended PCI config
space, only the low byte of the register number was being passed to XSM.
Include the correct value of the register if this feature is enabled;
otherwise, bits 24-30 of port cf8 are reserved, so disallow the invalid
access.

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Don't fail the permission check except when the MSR can't be read.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
Committed-by: Jan Beulich <jbeulich@suse.com>
13 years agoAMD IOMMU: add mechanism to protect their PCI devices' config spaces
Jan Beulich [Fri, 22 Jun 2012 11:43:00 +0000 (13:43 +0200)]
AMD IOMMU: add mechanism to protect their PCI devices' config spaces

Recent Dom0 kernels want to disable PCI MSI on all devices, yet doing
so on AMD IOMMUs (which get represented by a PCI device) disables part
of the functionality set up by the hypervisor.

Add a mechanism to mark certain PCI devices as having write protected
config spaces (both through port based [method 1] accesses and, for
x86-64, mmconfig), and use that for AMD's IOMMUs.

Note that due to ptwr_do_page_fault() being run first, there'll be a
MEM_LOG() issued for each such mmconfig based write attempt. If that's
undesirable, the order of the calls in fixup_page_fault() would need
to be swapped.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Wei Wang <wei.wang2@amd.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agolibxl: validate scheduler parameters
Ian Campbell [Fri, 22 Jun 2012 10:41:43 +0000 (11:41 +0100)]
libxl: validate scheduler parameters

This was previously done by xl itself however the domain was not
created at that point so there was no domid to check. This happened to
work on first boot because xl's global domid was initialised to zero
so we would (incorrectly) validate the new domain to be against
domain0. On reboot though we would try to use the old domain's id and
fail.

sched_params_valid is moved and gains a gc+domid parameters and
s/ctx/CTX/. The call is placed after
libxl__domain_build_info_setdefault in the create path, because
set_defaults doesn't have access to the domid and there are other
callers which don't even have a domid to give it.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agox86-64: revert mmconfig part of c/s 24425:053a44894279
Jan Beulich [Fri, 22 Jun 2012 08:05:05 +0000 (10:05 +0200)]
x86-64: revert mmconfig part of c/s 24425:053a44894279

These additions did not fulfill their purpose - they checked hypervisor
config space accesses instead of guest (Dom0) ones.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agox86/PCI: fix guest_io_read() when pci_cfg_ok() denies access
Jan Beulich [Fri, 22 Jun 2012 08:04:30 +0000 (10:04 +0200)]
x86/PCI: fix guest_io_read() when pci_cfg_ok() denies access

For a multi-byte aligned read, this so far resulted in 0x00ff to be
put in the guest's register rather than 0xffff or 0xffffffff, which in
turn could confuse bus scanning functions (which, when reading vendor
and/or device IDs, expect to get back all zeroes or all ones).

As the value gets masked to the read width when merging back into the
full result, setting the initial value to all ones should not harm any
or the other cases.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agoxl: fix sedf parameters checking
Dario Faggioli [Thu, 21 Jun 2012 12:43:18 +0000 (13:43 +0100)]
xl: fix sedf parameters checking

25468:9d1fd58ff602 was bogus in not letting a new domain being created
if its scheduling parameters --when running under the sedf scheduler--
were not fully specified, making creation fail like in this example
here below:

2012-06-16 07:37:47 Z executing ssh ... root@10.80.248.105 xl create /etc/xen/debian.guest.osstest.cfg
libxl: error: libxl.c:3619:sched_sedf_domain_set: setting domain sched sedf: Invalid argument
libxl: error: libxl_create.c:710:domcreate_bootloader_done: cannot (re-)build domain: -3
Parsing config from /etc/xen/debian.guest.osstest.cfg

This is due to the fact the values for period, slice, weight and
extratime should be consistent among each others, and if not all
are explicitly specified, someone has to make that happen. That
was right the purpose of the change in question, but it was failing
at achieving so.

This commit fixes things by forcing unspecified parameters to
sensible values, depending on the ones the user provided.

Signed-off-by: Dario Faggioli <dario.faggioli@citix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agox86/mm: fix mod_l1_entry() return value when encountering r/o MMIO page
Jan Beulich [Thu, 21 Jun 2012 09:30:59 +0000 (11:30 +0200)]
x86/mm: fix mod_l1_entry() return value when encountering r/o MMIO page

While putting together the workaround announced in
http://lists.xen.org/archives/html/xen-devel/2012-06/msg00709.html, I
found that mod_l1_entry(), upon encountering a set bit in
mmio_ro_ranges, would return 1 instead of 0 (the removal of the write
permission is supposed to be entirely transparent to the caller, even
more so to the calling guest).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agox86-64/EFI: document building and usage
Jan Beulich [Thu, 21 Jun 2012 09:30:22 +0000 (11:30 +0200)]
x86-64/EFI: document building and usage

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agox86-64: don't allow non-canonical addresses to be set for any callback
Jan Beulich [Mon, 18 Jun 2012 15:02:01 +0000 (17:02 +0200)]
x86-64: don't allow non-canonical addresses to be set for any callback

Rather than deferring the detection of these to the point where they
get actually used (the fix for XSA-7, 25480:76eaf5966c05, causing a #GP
to be raised by IRET, which invokes the guest's [fragile] fail-safe
callback), don't even allow such to be set.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Keir Fraser <keir@xen.org>
13 years agox86, cpufreq: Change powernow's CPB status immediately
Boris Ostrovsky [Mon, 18 Jun 2012 14:08:43 +0000 (15:08 +0100)]
x86, cpufreq: Change powernow's CPB status immediately

When command to modify turbo mode (CPB on AMD processors) comes
in the actual change happens later, when P-state transition is
requested. There is no time limit on when this transition will
occur and therefore change in CPB state may take long time from
the moment when command to toggle it is issued.

This patch makes CPB mode change happen immediately when request
is made.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@amd.com>
Committed-by: Keir Fraser <keir@xen.org>
13 years agolibxl: propagate down the error from libxl_domain_sched_params_set
Dario Faggioli [Thu, 14 Jun 2012 15:05:42 +0000 (16:05 +0100)]
libxl: propagate down the error from libxl_domain_sched_params_set

So that the caller (e.g., libxl__build_post() ) knows and can deal with it.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agoSVM: fix performance decrease with asid assignment
Christoph Egger [Wed, 13 Jun 2012 09:51:26 +0000 (11:51 +0200)]
SVM: fix performance decrease with asid assignment

Do not clear asid cleanbit unconditionally. This shaves off 100 cycles
from the VMRUN instruction.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Committed-by: Jan Beulich <jbeulich@suse.com>
13 years agox86-64: detect processors subject to AMD erratum #121 and refuse to boot
Jan Beulich [Tue, 12 Jun 2012 10:33:42 +0000 (11:33 +0100)]
x86-64: detect processors subject to AMD erratum #121 and refuse to boot

Processors with this erratum are subject to a DoS attack by unprivileged
guest users.

This is XSA-9 / CVE-2012-2934.

Signed-off-by: Jan Beulich <JBeulich@suse.com>
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agox86_64: Do not execute sysret with a non-canonical return address
Jan Beulich [Tue, 12 Jun 2012 10:33:40 +0000 (11:33 +0100)]
x86_64: Do not execute sysret with a non-canonical return address

Check for non-canonical guest RIP before attempting to execute sysret.
If sysret is executed with a non-canonical value in RCX, Intel CPUs
take the fault in ring0, but we will necessarily already have switched
to the the user's stack pointer.

This is a security vulnerability, XSA-7 / CVE-2012-0217.

Signed-off-by: Jan Beulich <JBeulich@suse.com>
Signed-off-by: Ian Campbell <Ian.Campbell@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Tested-by: Ian Campbell <Ian.Campbell@citrix.com>
Acked-by: Keir Fraser <keir.xen@gmail.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agox86: get rid of BOOT_TRAMPOLINE
Jan Beulich [Mon, 11 Jun 2012 14:15:28 +0000 (15:15 +0100)]
x86: get rid of BOOT_TRAMPOLINE

We recently saw a machine that has the EBDA extending as low as
0x7c000, so that Xen fails to boot after relocating the trampoline.
To fix this, I removed BOOT_TRAMPOLINE and bootsym_phys completely.

Here are the parts:

1) the trampoline segment is set to 64k below the EBDA.  head.S grows
the ability to relocate the trampoline segment

2) reloc.c is made position-independent.  It allocates data below the
trampoline, whose address is passed in _eax.

3) cmdline.S is called before relocating, so all bootsym_phys there
become sym_phys.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
jb: - fall back to low memory size (instead of segment 0x7c00) if EBDA
      value is out of range
    - also add upper limit check on EBDA value
    - fix and simplify inline assembly operands in reloc_mbi_struct()
    - use lret instead of retf
    - renamed early_stack to wakeup_stack, defined and used now only
      in wakeup.S
    - aligned reloc.bin's end of .text to 16 bytes, so that checking
      __bss_start == end works reliably

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Committed-by: Keir Fraser <keir@xen.org>
13 years agox86/nmi: Fix deadlock in unknown_nmi_error()
Andrew Cooper [Mon, 11 Jun 2012 14:12:50 +0000 (15:12 +0100)]
x86/nmi: Fix deadlock in unknown_nmi_error()

Additionally, correct the text description to reflect what is being
done, and make use of fatal_trap() in preference to kexec_crash() in
case an unknown NMI occurs before a kdump kernel has been loaded.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
13 years agogdbsx: send virq to guest if gdbsx_vcpu_event is not active
Mukesh Rathor [Mon, 11 Jun 2012 14:11:58 +0000 (15:11 +0100)]
gdbsx: send virq to guest if gdbsx_vcpu_event is not active

gdbsx got broken along the way. During domain pause, don't send
VIRQ_DEBUGGER to guest if gdbsx is active on that guest.

Signed-off-by: Mukesh Rathor <mukesh.rathor@oracle.com>
Committed-by: Keir Fraser <keir@xen.org>
13 years agoxl.cfg: document the cpuid= option
Olaf Hering [Fri, 8 Jun 2012 16:00:13 +0000 (17:00 +0100)]
xl.cfg: document the cpuid= option

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agotools/pygrub: Makefile cleanup
Anthony PERARD [Fri, 8 Jun 2012 15:43:25 +0000 (16:43 +0100)]
tools/pygrub: Makefile cleanup

This patch removes the extra command `install pygrub` because this is already
done by the setup.py script.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agotools/pygrub: Fix pygrub install
Anthony PERARD [Fri, 8 Jun 2012 15:42:50 +0000 (16:42 +0100)]
tools/pygrub: Fix pygrub install

The script pygrub is currently installed in the wrong location. Instead of
/usr/lib/xen/bin, the script is installed in $destdir/usr/lib/xen/bin.
$(DESTDIR) is apply twice.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
diff -r 474b5a6b1d91 -r 836e6618e86b tools/pygrub/Makefile
--- a/tools/pygrub/Makefile Fri Jun 08 16:39:24 2012 +0100
+++ b/tools/pygrub/Makefile Fri Jun 08 16:42:05 2012 +0100
@@ -12,7 +12,7 @@ build:
 install: all
  CC="$(CC)" CFLAGS="$(CFLAGS)" $(PYTHON) setup.py install \
  $(PYTHON_PREFIX_ARG) --root="$(DESTDIR)" \
- --install-scripts=$(DESTDIR)/$(PRIVATE_BINDIR) --force
+ --install-scripts=$(PRIVATE_BINDIR) --force
  $(INSTALL_PYTHON_PROG) src/pygrub $(DESTDIR)/$(PRIVATE_BINDIR)/pygrub
  $(INSTALL_DIR) $(DESTDIR)/var/run/xend/boot
  ln -sf $(PRIVATE_BINDIR)/pygrub $(DESTDIR)/$(BINDIR)

13 years agobuild: Correct typo introduced by c/s:25334
Juergen Gross [Fri, 8 Jun 2012 15:39:24 +0000 (16:39 +0100)]
build: Correct typo introduced by c/s:25334

Signed-off-by: Juergen Gross <juergen.gross@ts.fujitsu.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agotools: disable libvchan build on NetBSD
Roger Pau Monne [Fri, 8 Jun 2012 15:22:22 +0000 (16:22 +0100)]
tools: disable libvchan build on NetBSD

NetBSD doesn't have a gntdev, so libvchan is unable to build due to
the lack of the header files gntalloc.h.

This is the error:

gcc  -O1 -fno-omit-frame-pointer -m64 -g -fno-strict-aliasing
 -std=gnu99 -Wall -Wstrict-prototypes -Wdeclaration-after-statement
 -D__XEN_TOOLS__ -MMD -MF .init.o.d -fno-optimize-sibling-calls
 -I../include -I.
 -I/root/xen/xen-netbsd/tools/libvchan/../../tools/xenstore
 -I/root/xen/xen-netbsd/tools/libvchan/../../tools/include
 -I/root/xen/xen-netbsd/tools/libvchan/../../tools/libxc
 -I/root/xen/xen-netbsd/tools/libvchan/../../tools/include  -c -o init.o init.c
 init.c:45:30: fatal error: xen/sys/gntalloc.h: No such file or directory
compilation terminated.
gmake[3]: *** [init.opic] Error 1
gmake[3]: *** Waiting for unfinished jobs....
init.c:45:30: fatal error: xen/sys/gntalloc.h: No such file or directory
compilation terminated.

Signed-off-by: Roger Pau Monne <roger.pau@citrix.com>
Acked-by: Christoph Egger <Christoph.Egger@amd.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agolibxl: Store VNC passwd in xenstore with QEMU upstream.
Anthony PERARD [Fri, 8 Jun 2012 15:09:00 +0000 (16:09 +0100)]
libxl: Store VNC passwd in xenstore with QEMU upstream.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agolibxc: do not "panic" if a kernel is not a bzImage.
Ian Campbell [Fri, 8 Jun 2012 15:05:38 +0000 (16:05 +0100)]
libxc: do not "panic" if a kernel is not a bzImage.

Up until the point where we think this is a bzImage there is no point in
printing panicy messages -- some other loader will have a go (probably the
compressed ELF one)

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agotools: readnote: Add bzImage kernel support
Xuesen Guo [Fri, 8 Jun 2012 14:33:54 +0000 (15:33 +0100)]
tools: readnote: Add bzImage kernel support

Add the check of bzImage kernel and make it work
with RHEL 6 big zImage kernel

Signed-off-by: Xuesen Guo <Xuesen.Guo@hitachiconsulting.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agoxl: check for meaningful combination of sedf config file parameters
Dario Faggioli [Fri, 8 Jun 2012 14:26:01 +0000 (15:26 +0100)]
xl: check for meaningful combination of sedf config file parameters

As it happens in the implementation of `xl sched-sedf -d ...', some
consistency checking is needed for the scheduling parameters when
they come from the config file.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agoQEMU_TAG update
Ian Jackson [Thu, 7 Jun 2012 18:46:57 +0000 (19:46 +0100)]
QEMU_TAG update

13 years agotools: do not install qemu if just doing a build
David Vrabel [Thu, 7 Jun 2012 18:41:27 +0000 (19:41 +0100)]
tools: do not install qemu if just doing a build

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agoQEMU_TAG update
Ian Jackson [Thu, 7 Jun 2012 18:40:23 +0000 (19:40 +0100)]
QEMU_TAG update

13 years agotools: pass EXTRA_CFLAGS via environment
Olaf Hering [Thu, 7 Jun 2012 17:51:42 +0000 (18:51 +0100)]
tools: pass EXTRA_CFLAGS via environment

Currently qemu-xen will be compiled with CFLAGS only if CFLAGS was
already in the environment during make invocation. If CFLAGS is in
environment then make will append all of the various flags specified in
xen Makefiles to this environment variable, which is then used in qemu
configure. Since qemu-xen is not ready for compiler flags like
"-std=gnu99" compilation will fail. If CFLAGS is not in environment,
then configure will use just its own "-O2 -g" because make does not
export its own CFLAGS variable.

>From a distro perspective, it is required to build libraries and
binaries with certain global cflags (arbitrary gcc options). Up to the
point when qemu-xen was imported it worked as expected by exporting
CFLAGS before 'make tools'.  Now qemu-upstream reuses these CFLAGS, but
it cant deal with the result.

This patch extends the tools Makefiles so that three new environment
variables are recognized:
  EXTRA_CFLAGS_XEN_TOOLS= specifies CFLAGS for the tools build.
  EXTRA_CFLAGS_QEMU_TRADITIONAL= specifies CFLAGS for old qemu.
  EXTRA_CFLAGS_QEMU_XEN= specifies CFLAGS for new qemu.

Special care needs to be taken in tools/firmware because the resulting
binaries are not linked with the hosts runtime libraries. These binaries
run in guest context. To avoid build errors from gcc options like
-fstack-protector, reuse existing practice to unset the new
EXTRA_CFLAGS_XEN_TOOLS for the firmware dirs.

The new feature can be used like this in a rpm xen.spec file:

   export EXTRA_CFLAGS_XEN_TOOLS="${RPM_OPT_FLAGS}"
   export EXTRA_CFLAGS_QEMU_TRADITIONAL="${RPM_OPT_FLAGS}"
   export EXTRA_CFLAGS_QEMU_XEN="${RPM_OPT_FLAGS}"
   ./configure \
    --libdir=%{_libdir} \
    --prefix=/usr
   make

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agoxend: do not run a hotplug script from qemu on Linux
Ian Campbell [Thu, 7 Jun 2012 17:45:22 +0000 (18:45 +0100)]
xend: do not run a hotplug script from qemu on Linux

The current vif-hotplug-common.sh for renaming the tap device is failing
because it is racing with this script and therefore the device is unexpectedly
up when we come to rename it.

Fix this in the same way as libxl does, by disabling the script (only on
Linux).

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agolibxl: remove libxl__error_set prototype
Ian Campbell [Thu, 7 Jun 2012 17:34:25 +0000 (18:34 +0100)]
libxl: remove libxl__error_set prototype

The implementation went away in 25181:26f72d923cb9 "libxl: Crash (more
sensibly) on malloc failure".

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agoxenstore: set read_thread stacksize
Simon Rowe [Thu, 7 Jun 2012 17:23:00 +0000 (18:23 +0100)]
xenstore: set read_thread stacksize

xs_watch() creates a thread to wake watchers using default attributes. The
stacksize can be quite large (8 MB on Linux), applications that link against
xenstore end up having a larger memory footprint than necessary.

Signed-off-by: Simon Rowe <simon.rowe@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agoxenstore: block signals in watch wakeup thread
Simon Rowe [Thu, 7 Jun 2012 17:22:20 +0000 (18:22 +0100)]
xenstore: block signals in watch wakeup thread

The thread created to wakeup watchers is not intended to handle signals
(and a later patch will reduce it's stack size which makes it unsuitable
for doing so).

Signed-off-by: Simon Rowe <simon.rowe@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agoxen: fix page_list_splice()
Jan Beulich [Wed, 6 Jun 2012 15:37:05 +0000 (16:37 +0100)]
xen: fix page_list_splice()

Other than in __list_splice(), the first element's prev pointer
doesn't need adjustment here - it already is PAGE_LIST_NULL. Rather
than fixing the assignment (to formally match __list_splice()), simply
assert that this assignment is really unnecessary.

Reported-by: Jisoo Yang <jisooy@gmail.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Also assert that the prev pointers are both PAGE_LIST_NULL.

Signed-off-by: Keir Fraser <keir@xen.org>
Committed-by: Keir Fraser <keir@xen.org>
13 years agoxenpm, x86: Fix reporting of idle state average residency times
Boris Ostrovsky [Wed, 6 Jun 2012 15:34:53 +0000 (16:34 +0100)]
xenpm, x86: Fix reporting of idle state average residency times

If CPU stays in the same idle state for the full duration of
xenpm sample then average residency may not be reported correctly
since usage counter will not be incremented.

In addition, in order to calculate averages correctly residence
time and usage counter should be read and written atomically.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@amd.com>
Committed-by: Keir Fraser <keir@xen.org>
13 years agoxen: enhance dump_numa output
Dario Faggioli [Wed, 6 Jun 2012 15:33:21 +0000 (16:33 +0100)]
xen: enhance dump_numa output

By showing the number of free pages on each node.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Keir Fraser <keir@xen.org>
13 years agolibxl: introduce LIBXL_DOMAIN_TYPE_INVALID
Dario Faggioli [Wed, 6 Jun 2012 14:57:08 +0000 (15:57 +0100)]
libxl: introduce LIBXL_DOMAIN_TYPE_INVALID

To avoid recent gcc complaining about:
libxl.c: In function 'libxl_primary_console_exec':
libxl.c:1233:9: error: case value '4294967295' not in enumerated type 'libxl_domain_type' [-Werror=switch]

Also:
 - have all the call sites of libxl__domain_type() return with error in
   case the function returns LIBXL_DOMAIN_TYPE_INVALID;
 - adjust all other code segments where -Wswitch makes would claim that
   LIBXL_DOMAIN_TYPE_INVALID is not handled by adding a "default: abort();"
   clause.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
[ ijc -- use LIBXL_DOMAIN_TYPE_INVALID instead of -1 for
         libxl_domain_build_info.type's keyvar_init_val.
      -- what used to be libxl_primary_console_exec is now in
         libxl__primary_console_find so resolve the rejected hunk
         accordingly ]
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoxl.cfg: document the maxmem= option
Olaf Hering [Wed, 6 Jun 2012 12:53:59 +0000 (13:53 +0100)]
xl.cfg: document the maxmem= option

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl: Add API to retrieve domain console tty
Bamvor Jian Zhang [Wed, 6 Jun 2012 11:46:18 +0000 (12:46 +0100)]
libxl: Add API to retrieve domain console tty

This api retrieve domain console from xenstore. With this new api, it is easy
to implement "virsh console" command in libvirt libxl driver.

Signed-off-by: Bamvor Jian Zhang <bjzhang@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
[ ijc -- use NOGC instead of 0 to allow improvements to this infrastructure
         in the future ]
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl: convert malloc() to libxl__zalloc(NULL, ...)
Dario Faggioli [Wed, 6 Jun 2012 11:46:17 +0000 (12:46 +0100)]
libxl: convert malloc() to libxl__zalloc(NULL, ...)

And ditch the error handling in libxl_get_cpu_topology()

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
[ ijc -- define and use NOGC instead of NULL to allow improvements to this
          infrastructure in the future ]
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoocaml: fix build after 25446:648508ee27a2, 25449:68d46c5ea0a3 et al.
Ian Campbell [Sat, 2 Jun 2012 07:39:45 +0000 (08:39 +0100)]
ocaml: fix build after 25446:648508ee27a2, 25449:68d46c5ea0a3 et al.

These renamed a type and the associated functions and the ocaml bindings were
not updated to suit.

This also highlighted that libxl_domain_sched_params should not be DIR_IN since
it is also use as an output struct.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl: fix Makefile race bug relating to _paths.h
Ian Jackson [Fri, 1 Jun 2012 17:02:03 +0000 (18:02 +0100)]
libxl: fix Makefile race bug relating to _paths.h

_paths.h needs to be in AUTOINCS.  That arranges for it to be an
explicit dependency of all object files.  This is necessary so that it
is made before any compilation is attempted.

Making it a dependency of xl.h (as in 25426:e53a1d3c212c) is harmless,
but not sufficient because that only takes effect if there is already
an autogenerated .d file naming xl.h as a dependency of relevant
object files.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
13 years agolibxl: fix typos in libxl_cpuid_parse_config
Olaf Hering [Fri, 1 Jun 2012 11:06:22 +0000 (12:06 +0100)]
libxl: fix typos in libxl_cpuid_parse_config

Fix typo in comment.
Fix cpuid_flags array init, use correct number of arguments for empty
array entry.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl: expose a single get/setter for domain scheduler parameters
Ian Campbell [Fri, 1 Jun 2012 11:06:21 +0000 (12:06 +0100)]
libxl: expose a single get/setter for domain scheduler parameters

This is consistent with having a single struct for all parameters.

Effectively renames and exports libxl__sched_set_params as
libxl_domain_sched_params_set. libxl_domain_sched_params_get is new.

Improve const correctness of the setters while I'm here.

Use shorter LOG macros when touching a line anyway.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl: move libxl__sched_set_params into libxl.c
Ian Campbell [Fri, 1 Jun 2012 11:06:20 +0000 (12:06 +0100)]
libxl: move libxl__sched_set_params into libxl.c

All the other sched functions are here and I'm just about to make those static
functions as I make libxl__sched_set_params the public function.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl: make it possible to explicitly specify default sched params
Ian Campbell [Fri, 1 Jun 2012 11:06:20 +0000 (12:06 +0100)]
libxl: make it possible to explicitly specify default sched params

To do so we define a discriminating value which is never a valid real value for
each parameter.

While there:

 - removed libxl_sched_*_domain in favour of libxl_domain_sched_params.
 - use this new functionality for the various xl commands which set sched
   parameters, which saves an explicit read-modify-write in xl.
 - removed call of xc_domain_getinfolist from a few functions which weren't
   actually using the result (looks like a cut and paste error)
 - fix xl which was setting period for a variety of different config keys.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl: rename libxl_sched_params to libxl_domain_sched_params
Ian Campbell [Fri, 1 Jun 2012 11:06:19 +0000 (12:06 +0100)]
libxl: rename libxl_sched_params to libxl_domain_sched_params

Remove credit scheduler global options from the struct, they were never used
anyway.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agolibxl: add internal function to get a domain's scheduler
Ian Campbell [Fri, 1 Jun 2012 11:06:18 +0000 (12:06 +0100)]
libxl: add internal function to get a domain's scheduler

This takes into account cpupools.

Add a helper to get the info for a single cpu pool, refactor libxl_list_cpupool
t use this. While there fix the leaks due to not disposing the partial list on
realloc failure in that function.

Fix the failure of sched_domain_output to free the poolinfo list.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoarm: Enable VFP at boot
Tim Deegan [Fri, 1 Jun 2012 09:20:40 +0000 (10:20 +0100)]
arm: Enable VFP at boot

Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoarm: allow ourselves access to all coprocessors in non-secure mode
Tim Deegan [Fri, 1 Jun 2012 09:20:39 +0000 (10:20 +0100)]
arm: allow ourselves access to all coprocessors in non-secure mode

We'll need it to be able to use the VFP extensions, for example.

Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
13 years agoarm: missing __init annotation
Tim Deegan [Fri, 1 Jun 2012 09:20:39 +0000 (10:20 +0100)]
arm: missing __init annotation

Signed-off-by: Tim Deegan <tim@xen.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>